package Java_Concurrency_in_Practice.this_escape;

/**
 * @author lixiangke
 * @date 2018/6/21
 */
public class ThisEscape {

    public final int id;
    public final String name;

    public ThisEscape(EventSource<EventListener> source) {
        id = 1;
        source.registerListener(new EventListener() {
            public void onEvent(Object obj) {
                // ThisEscape.this 溢出
                // ThisEscape 对象未构造完成，这里就可以使用 ThisEscape 了
                System.out.println("id: " + ThisEscape.this.id);
                System.out.println("name: " + ThisEscape.this.name);
            }
        });
        name = "flysqrlboy";

    }
}
